namespace Todos.Infrastructure.EntityFrameworkCore.Configurations;

public class TodoListConfiguration : EntityConfigurationBase<TodoList>
{
    public override void Configure(EntityTypeBuilder<TodoList> builder)
    {
        builder.Property(e => e.Name).HasMaxLength(255).IsRequired();

        builder.HasOne(m => m.User).WithMany().HasForeignKey(n => n.UserId).OnDelete(DeleteBehavior.Cascade);
        builder.HasMany(m => m.Items).WithOne().HasForeignKey(n => n.ListId).IsRequired();
    }
}
